package com.sinven.convert;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import org.springframework.core.convert.converter.Converter;

public class DateConverter implements Converter<String, Date> {

	private String pettrn = "yyyy-MM-dd";

	public void setPettrn(String pettrn) {
		this.pettrn = pettrn;
	}

	@Override
	public Date convert(String source) {
		SimpleDateFormat smf = new SimpleDateFormat(pettrn);
		Date date = null;
		try {
			date = smf.parse(source);
		} catch (ParseException e) {
			e.printStackTrace();
			date = new Date();
		}

		return date;
	}
}
